#!/GPUFS/app_GPU/application/anaconda3/5.3.1/envs/python-3.6/bin/python
import os

config_path = '/GPUFS/igsnrr_czqin_2/shenshen/SEIMS/data/youwuzhen/workspace/'
config_files = ['preprocess.ini', 'runmodel.ini', 'postprocess.ini', 'sensitivity_analysis.ini',
                'calibration.ini', 'scenario_analysis.ini', 'scenario_analysis_time.ini']
ip_new = '10.103.207.101'
new_line = 'HOSTNAME = {0}{1}'.format(ip_new, '\n')

for cf in config_files:
    cfg_filename = config_path + cf
    lines = []
    with open(cfg_filename, "r") as fpi:
        for line in fpi:
            if line.find('HOSTNAME') != -1:
                line = new_line
            lines.append(line)
    with open(cfg_filename, 'w') as fpo:
        for line in lines:
            fpo.write(line)
    print('finish '+cfg_filename)

